package com.backend.district.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.backend.common.annotation.Log;
import com.backend.common.core.controller.BaseController;
import com.backend.common.core.domain.AjaxResult;
import com.backend.common.enums.BusinessType;
import com.backend.district.domain.SysDistrict;
import com.backend.district.service.ISysDistrictService;
import com.backend.common.utils.poi.ExcelUtil;
import com.backend.common.core.page.TableDataInfo;

/**
 * 省市县地址Controller
 * 
 * @author fusi
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/district/district")
public class SysDistrictController extends BaseController
{
    @Autowired
    private ISysDistrictService sysDistrictService;

    /**
     * 查询省市县地址列表
     */
    @PreAuthorize("@ss.hasPermi('district:district:list')")
    @GetMapping("/list")
    public TableDataInfo list(Long id)
    {
        List<SysDistrict> list = sysDistrictService.selectSysDistrictList(id);
        return getDataTable(list);
    }

    /**
     * 查询顶级城市列表
     */
    @PreAuthorize("@ss.hasPermi('district:district:list')")
    @GetMapping("/topCityList")
    public TableDataInfo listTopCity()
    {
        List<SysDistrict> list = sysDistrictService.selectTopCityList();
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('district:district:list')")
    @GetMapping("/cityListByName")
    public TableDataInfo selectCityListByName(String name)
    {
        List<SysDistrict> list = sysDistrictService.selectCityListByName(name);
        return getDataTable(list);
    }
}
